<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/module/index/_taglib.jsp" %>
<!DOCTYPE html>
<html>
	<head>
		<title>JC mms</title>
		<jsp:include page="/_loadCssScript.jsp"></jsp:include>
		<script type="text/javascript">
			$(function(){
				
				/*/
				var sendDate = $(":input[name='sendDate']");
				sendDate.datepicker();
				sendDate.datepicker("option","dateFormat","yy-mm-dd");
				//*/
				// 表单ajax提交
				function formSubmit() {
					//bootbox.dialog("<div class='progress progress-striped active'><div class='bar' style='width: 100%;'></div></div>");
					var saveBtn = $('#saveBtn');
					var form = $("form:first");
					saveBtn.button('loading');
					var action = form.attr("action");
					var params = form.serialize();
					$.post(action, params, function(data){
						if (data.RESULT = "SUCCESS") {
							form.get(0).reset(); // 表单
							saveBtn.button('reset'); // 按钮状态还原
							$("#resultDialog #successLabel").show();
							$("#resultDialog .modal-body p").html("ID: " + data.id);
							// 【编辑帧】按钮响应
							var editFrameButton = $("#editFrameButton");
							var editFrameUrl = editFrameButton.attr("href").substr(1);
							editFrameButton.off("click");
							editFrameButton.on("click", function(){
								editFrameUrl += ("?mmsId=" + data.id);
								window.location.href = editFrameUrl;
								return false;
							});
							// 弹出对话框
							$("#resultDialog").modal({
								"backdrop"  : "static",
							    "keyboard"  : true,
							    "show"      : true
							});
						} else {
							alert("保存失败");
						}
					});
				}
				
				// 表单验证
				$("form:first").validate({
					submitHandler: function(form){
						//form.submit();
						formSubmit();
					},
					rules: {
						name:{
							required: true,
						    maxlength: 50
						},
						sendDate:{
							dateISO: true
						}
					}
				});
				
				// 【保存】按钮响应
				$("#saveBtn").click(function(){
					$("form:first").submit();
				});
				
			});
		</script>
	</head>
	<body>
		<jsp:include page="/module/index/_top_navbar.jsp"></jsp:include>
		
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span2">
					<jsp:include page="/module/index/_menu.jsp"></jsp:include>
				</div>
				<div class="span10">
					<!-- 站点路径 -->
					<ul class="breadcrumb">
						<li><a href="<%=request.getContextPath() %>/">首页</a> <span class="divider">/</span></li>
						<li><a href="javascript:void(0);">内容管理</a> <span class="divider">/</span></li>
						<li class="active">内容上传</li>
					</ul>
					
					<ul class="nav nav-tabs">
						<li class="active">
							<a href="javascript:void(0)">内容上传</a>
						</li>
						<li><a href="javascript:void(0)">帧编辑</a></li>
					</ul>
					
					<form action="<%=request.getContextPath() %>/module/mms/ajaxAdd.do" method="post" class="form-horizontal">
						<div class="row-fluid">
							<div class="span5">
								<fieldset>
									<legend>内容基本信息</legend>
									<div class="control-group">
										<label class="control-label" for="inputName">内容名称</label>
										<div class="controls">
											<input type="text" id="inputName" name="name" class="input-xlarge">
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputKeyWord">关键字</label>
										<div class="controls">
											<input type="text" id="inputKeyWord" name="keyWord" class="input-xlarge">
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputContentCategoryId">所属分类</label>
										<div class="controls">
											<input type="text" id="inputContentCategoryId" name="contentCategoryId" class="input-xlarge">
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputNumber">内容编号</label>
										<div class="controls">
											<input type="text" id="inputNumber" name="number" class="input-xlarge">
										</div>
									</div>
								</fieldset>
							</div>
							<div class="span5">
								<fieldset>
									<legend>内容详细信息</legend>
									<div class="control-group">
										<label class="control-label" for="inputMmsTopic">彩信主题</label>
										<div class="controls">
											<input type="text" id="inputMmsTopic" name="mmsTopic" class="input-xlarge">
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputMmsNumber">彩信编号</label>
										<div class="controls">
											<span class="input-xlarge uneditable-input"></span>
											<!-- <input type="text" id="inputMmsNumber" name="mmsNumber" class="input-xlarge"> -->
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputCallbackUrl">回访URL地址</label>
										<div class="controls">
											<span class="input-xlarge uneditable-input"></span>
											<!-- <input type="text" id="inputCallbackUrl" name="callbackUrl" class="input-xlarge"> -->
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputCallbackUrlFrame">URL地址所在帧</label>
										<div class="controls">
											<span class="input-xlarge uneditable-input"></span>
											<!-- <input type="text" id="inputCallbackUrlFrame" name="callbackUrlFrame" class="input-xlarge"> -->
										</div>
									</div>
									<div class="control-group">
										<label class="control-label" for="inputSendDate">发送日期</label>
										<div class="controls">
											<span class="input-xlarge uneditable-input"></span>
											<!-- <input type="text" id="inputSendDate" name="sendDate" class="input-xlarge"> -->
										</div>
									</div>
								</fieldset>
							</div>
						</div>
					
						<div class="form-actions">
							<button id="saveBtn" type="button" class="btn btn-primary" data-loading-text="保存中...">保存</button>
						</div>
					</form>
				</div>
			</div>
		</div>

		<div id="resultDialog" class="modal hide fade">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<span id="successLabel" class="label label-success">保存成功</span>
				<span id="failLabel" style="display: none;" class="label label-important">保存失败</span>
			</div>
			<div class="modal-body">
				<p></p>
			</div>
			<div class="modal-footer">
				<a href="#resultDialog" role="button" class="btn" data-toggle="modal">关闭</a>
				<a id="editFrameButton" href="#<%=request.getContextPath() %>/module/frame/toAdd.do" class="btn btn-primary">编辑帧</a>
			</div>
		</div>
	</body>
</html>